trainFile = open('training.txt', 'rb')
trainRealFile = open('synset_words.txt', 'ab')

index = []
indexNumber = -1

for oneline in trainFile.readlines():
    onelineIndex = oneline.split('/', 1)[0]
    if onelineIndex not in index:
        index.append(onelineIndex)
        indexNumber = indexNumber + 1
        realOut = onelineIndex.strip() + ' ' + str(indexNumber) + '\n'
        print realOut
    	trainRealFile.write(realOut)
